package com.zjff.mobiletwo.controller;

import com.zjff.mobiletwo.entity.AddressEntity;
import com.zjff.mobiletwo.service.IAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin//跨域
@RestController//遵循RestFul
@RequestMapping("v2/Address/")
public class AddressController {
    @Autowired
    private IAddressService addressService;

    @PutMapping ("addnewaddress")
    public String addNewAddress(Integer uid, String username, AddressEntity addressEntity) {
        // 调用业务对象的方法执行业务
        String data = addressService.addNewAddress(uid, username, addressEntity);
        // 响应成功
        return data;
    }
    @GetMapping({"getaddlist"})
    public String getByUid(Integer uid) {
        String data = addressService.getByUid(uid);
        return data;
    }
    @PutMapping ("setdefault")
    public String setDefault(Integer aid, Integer uid, String username) {
        String data = addressService.setDefault(aid, uid, username);
        return data;
    }
    @DeleteMapping("deleteaddress")
    public String delete(Integer aid,Integer uid, String username) {
        String data = addressService.delete(aid, uid, username);
        return data;
    }
    @PutMapping("updataddress")
    public String updateByAid(Integer aid,Integer uid,String username,String name,String provinceName,String provinceCode,
                              String cityName,String cityCode,String areaName,String areaCode,String zip,
                              String address,String phone,String tag,Integer isDefault) {
        String data = addressService.updateByAid(
                aid, uid, username,name, provinceName, provinceCode, cityName, cityCode, areaName,
                areaCode, zip, address, phone, tag, isDefault);
        return data;
    }
}
